{extend name="admin@index_layout"/}
{block name="main"}
<link rel="stylesheet" href="__STATIC__/admin/css/cms.css">
<form class="layui-form" method="post">
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li class="layui-this"><i class="layui-icon layui-icon-set"></i> 基本设置</li>
            <li id="modeTab"><i class="layui-icon layui-icon-template"></i> 模板设置</li>
            {volist name="site" id="site"}
            <li> {if $site.mark} <img src="/static/lang/image/{$site.mark}.png" title="{$site.name}">{/if} {$site.name}</li>
            {/volist}
            {php}$info=get_addon_info('member');{/php}
            {if $info && $info['status']>0}
            <li><i class="layui-icon layui-icon-auz"></i> 权限设置</li>
            {/if}
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">

                <div class="layui-form-item"  {if $isall}style="display: none"{/if}>
                    <label class="layui-form-label">所属站点</label>
                    <div class="layui-input-block check-box">
                        <input lay-skin="primary" type="checkbox" id="checkall" name="checkall" lay-filter="allChoose" value=""/><span>全选</span>
                        {volist name="sites" id="vo"}
                        <input type="checkbox" name="sites[]" value="{$vo.id}" lay-skin="primary"  title="{$vo.name}" {if $data && in_array($vo.id,$data.sites)}checked{/if}>
                        {/volist}
                    </div>
                    <div class="layui-form-mid layui-word-aux">只有选了某些站，在管理内容时才显示</div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">上级菜单</label>
                    <div class="layui-input-block">
                        <select name="parentid">
                            <option value="0">作为顶级栏目</option>
                            {$category|raw}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">栏目标题 </label>
                    <div class="layui-input-block">
                        <input type="text" name="catname" autocomplete="off" lay-verify="required" placeholder="栏目名称" class="layui-input" value="{$data.catname}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">唯一标识</label>
                    <div class="layui-input-block">
                        <input type="text" name="catdir" autocomplete="off" placeholder="唯一标识" class="layui-input" value="{$data.catdir}">
                    </div>
                    <div class="layui-form-mid layui-word-aux">英文数字组成，留空则自动生成拼音</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">英文标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="english" autocomplete="off" placeholder="部分中文企业站栏目标题后会有英文标题" class="layui-input" value="{$data.english}">
                    </div>
                    <div class="layui-form-mid layui-word-aux">部分中文企业站栏目标题后会有英文标题</div>
                </div>
                <div class="layui-form-item web_link">
                    <label class="layui-form-label">链接地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="url" autocomplete="off" placeholder="自定义链接地址" class="layui-input" id="url" value="{$data.url}">
                    </div>
                    <div class="layui-input-inline">
                        <select lay-filter="fasttype">
                            <option data-url="">常用内部链接</option>
                            <option data-url="cms/index/index">首页</option>
                            {if isset(cache("Cms_Config")['site_url_mode']) && 1==cache("Cms_Config")['site_url_mode']}
                            <option data-url="cms/index/lists?catid=2">列表页/单页</option>
                            <option data-url="cms/index/shows?catid=2&id=1">详情页</option>
                            {else}
                            <option data-url="cms/index/lists?catdir=Introduction">列表页/单页</option>
                            <option data-url="cms/index/shows?catdir=Introduction&id=1">详情页</option>
                            {/if}
                            {php}$info=get_addon_info('formguide');{/php}
                            {if $info && $info['status']>0}
                            <option data-url="formguide/index/index?id=2">表单页</option>
                            {/if}
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux">有值时生效，内部链接格式:模块/控制器/操作?参数=参数值&...，外部链接则必须http://开头</div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">栏目图片</label>
                    <div class="layui-input-block layui-upload">
                        {:Form::image("image",$data['image'])}
                    </div>
                </div>
                {if isset(cache("Cms_Config")['icon_mode']) && 1==cache("Cms_Config")['icon_mode']}
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">栏目图标</label>
                    <div class="layui-input-block layui-upload">
                        {:Form::image("icon",$data['icon'])}
                    </div>
                </div>
                {else}
                <div class="layui-form-item">
                    <label class="layui-form-label">栏目图标</label>
                    <div class="layui-input-block">
                        <input type="text" name="icon" autocomplete="off" placeholder="栏目图标格式iconfont-icon或layui-icon-rate" class="layui-input" value="{$data.icon}">
                    </div>
                    <div class="layui-form-mid layui-word-aux">手动输入字体样式：如iconfont-icon或layui-icon-rate</div>
                </div>
                {/if}

                <div class="layui-form-item">
                    <label class="layui-form-label">在导航显示</label>
                    <div class="layui-input-block">
                        <input type="radio" name="status" value="1" title="显示" {eq name="data.status" value="1" }checked{/eq}>
                        <input type="radio" name="status" value="0" title="隐藏" {eq name="data.status" value="0" }checked{/eq}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">新窗口打开</label>
                    <div class="layui-input-block">
                        <input type="radio" name="target" value="1" title="是" {eq name="data.target" value="1" }checked{/eq}>
                        <input type="radio" name="target" value="0" title="否" {eq name="data.target" value="0" }checked{/eq}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">显示排序</label>
                    <div class="layui-input-block">
                        <input type="text" name="listorder" autocomplete="off" placeholder="显示排序" class="layui-input" value="{$data['listorder']}">
                    </div>
                </div>
            </div>
            <div class="layui-tab-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">栏目首页模板</label>
                    <div class="layui-input-block">
                        <select name="setting[category_template]">
                            <option value="category.{:config('template.view_suffix')}" selected>默认栏目首页:category.{:config('template.view_suffix')}</option>
                            {volist name="tp_category" id="vo"}
                            <option value="{$vo}" {eq name="setting['category_template']" value="$vo" }selected{/eq}>{$vo} </option>
                            {/volist}
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux">新增模板以category_xx.{:config('template.view_suffix')}形式,【含有子栏目时生效】</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">栏目列表模板</label>
                    <div class="layui-input-block">
                        <select name="setting[list_template]">
                            <option value="list.{:config('template.view_suffix')}" selected>默认栏目列表页:list.{:config('template.view_suffix')}</option>
                            {volist name="tp_list" id="vo"}
                            <option value="{$vo}" {eq name="setting['list_template']" value="$vo" }selected{/eq}>{$vo} </option>
                            {/volist}
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux">新增模板以list_xx.{:config('template.view_suffix')}形式,【没有子栏目时生效】</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">内容页模板</label>
                    <div class="layui-input-block">
                        <select name="setting[show_template]">
                            <option value="show.{:config('template.view_suffix')}" selected>默认内容页:show.{:config('template.view_suffix')}</option>
                            {volist name="tp_show" id="vo"}
                            <option value="{$vo}" {eq name="setting['show_template']" value="$vo" }selected{/eq}>{$vo} </option>
                            {/volist}
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux">新增模板以show_xx.{:config('template.view_suffix')}形式</div>
                </div>

                <div class="layui-form-item"  {if $modelType!=3}style="display:none"{/if}>
                    <label class="layui-form-label">章节页模板</label>
                    <div class="layui-input-block">
                        <select name="setting[chapter_template]">
                            <option value="chapter.{:config('template.view_suffix')}" selected>默认章节页:chapter.{:config('template.view_suffix')}</option>
                            {volist name="tp_chapter" id="vo"}
                            <option value="{$vo}" {eq name="setting['chapter_template']" value="$vo" }selected{/eq}>{$vo} </option>
                            {/volist}
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux">新增模板以chapter_xx.{:config('template.view_suffix')}形式</div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">应用到子栏目</label>
                    <div class="layui-input-block">
                        <input type="radio" name="template_child" value="1" title="是">
                        <input type="radio" name="template_child" value="0" title="否" checked>
                    </div>
                </div>
            </div>

            <!-- 多语言设置 -->
            {volist name="category_data" id="s" key="k"}
            {include file="/cms/item_category" /}
            {/volist}
            <!-- 多语言设置 end-->
            <div class="layui-tab-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">会员组权限</label>
                    <table class="layui-table auth-list">
                        <colgroup>
                            <col width="150">
                            <col width="100">
                            <col width="100">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>会员组名称</th>
                            <th>允许投稿</th>
                            <th>允许访问</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="Member_Group" id="vo"}
                        <tr>
                            <td>{$vo.name}</td>
                            <td><input type="checkbox" name="priv_groupid[]" value="add,{$vo.id}" title="允许" lay-skin="primary" {php} echo model("admin/cms/CategoryPriv")->check_category_priv($privs,'add',$vo['id'],0);{/php}></td>
                            <td><input type="checkbox" name="read_groupid[]" value="add,{$vo.id}" title="允许" lay-skin="primary" {php} echo model("admin/cms/CategoryRead")->check_category_read($reads,'add',$vo['id'],0);{/php}></td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                {include file="/cms/help_category" /}
            </div>


        </div>
        <input type="hidden" name="modelid" value="{$data.modelid}">
        <input type="hidden" name="type" value="2">
        <input name="id" type="hidden" value="{$data.id}">
        <div class="layui-form-item layer-footer">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit>立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </div>
</form>
{/block}
{block name="script"}
<script type="text/javascript">
    layui.use(['form','yznForm'], function() {
        var form = layui.form,
            yznForm = layui.yznForm;

        yznForm.listen();
        //点击全选, 勾选
        form.on('checkbox(allChoose)', function (data) {
            var child = $(".check-box input[type='checkbox']");
            child.each(function (index, item) {
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });
        form.on('select(fasttype)', function(data) {
            $('#url').val($(data.elem).find("option:selected").attr("data-url"));
        });
    });
</script>
{/block}
